<template>
  <div>
    <Head></Head>
    <scroller @loadEvent="freshDemands" ref="scroller">
      <span v-show="DataLoading" class="loadingstatus"><spinner type="ios-small"></spinner>加载中...</span>
      <a class="txf-list-box" v-for="item in listcon" :href="item.url" :key="item.id">
        <div class="txf-list-box-hd" :style="{backgroundImage: 'url(' + item.pic + ')'}"></div>
        <div class="txf-list-box-bd">
          <h4 class="txf-list-box-bd_title">{{ item.title }}</h4>
          <ul class="txf-list-box-bd_info">
            <li>{{ item.catname }}</li>
            <li>{{ item.addtime }}</li>
            <li>{{ item.viewnum }}阅读</li>
          </ul>
        </div>
      </a>
    </scroller>
  </div>
</template>

<script>
import Head from "@/components/Head";
import { Spinner } from "vux"
import Scroller from "@/components/Scroller"

export default {
  components: {
    Head,
    Scroller,
    Spinner
  },
  data() {
    return {
      DataLoading: true,
      listcon: [],
      currentP: 1,
      currentPS: 10,
      pullupEnabled: true,
      status: {
        pullupStatus: "default",
        pulldownStatus: "default"
      },
      toStatus: false
    };
  },
  mounted() {
    this.getListData();
  },
  methods: {
    getListData(){
      return _axios
      .get('api/portal/home/articles', {
        params: {
          category: this.$route.params.catid,
          page: this.currentP,
          pageSize: this.currentPS
        }
      })
      .then(response => {
        // this.listcon = response.data.data;
        var data = response.data.resp_data;
        setTimeout(() => {
          for (var i = 0; i < data.length; i++) {
            this.listcon.push(data[i]);
          }
          this.DataLoading = false;
        }, 1000)
      });
    },
    loadMore () {
      this.currentP ++;
      this.getListData();
      this.$nextTick(() => {
        this.$refs.scroller.donePullup();
      })
    },
    touch () {
      this.toStatus = !this.toStatus;
    }
  },
  watch: {
    $route() {
      this.catid = this.$route.params.catid
      this.listcon = []
      this.getListData()
      this.DataLoading = true
    }
  }
};
</script>

<style>
@import url("../../styles/common/portal/index.css");
.weui-tabbar{
  display:none
}
</style>
